#!/bin/bash

set -e

rm -rf ./openwisp_controller/geo/tests/.pytest_cache \
       ./openwisp_controller/config/tests/.pytest_cache/ \
       ./openwisp_controller/connection/tests/.pytest_cache/ \
       ./openwisp_controller/.pytest_cache/ \
       ./tests/openwisp2/sample_geo/.pytest_cache \
       ./tests/.pytest_cache \
       ./tests/openwisp2/.pytest_cache/ \
       ./htmlcov/ 2> /dev/null || true

openwisp-qa-check \
  --csslinter \
  --jslinter \
  --migrations-to-ignore "12 0 0 4" \
  --migration-path "./openwisp_controller/config/migrations
                  ./openwisp_controller/connection/migrations
                  ./openwisp_controller/geo/migrations
                  ./openwisp_controller/pki/migrations
                  ./openwisp_controller/subnet_division/migrations"

echo ''
echo 'Running checks for SAMPLE_APP'
SAMPLE_APP=1 openwisp-qa-check \
  --skip-isort \
  --skip-flake8 \
  --skip-black \
  --skip-checkendline \
  --skip-checkcommit \
  --migration-path "./tests/openwisp2/sample_config/migrations/
                    ./tests/openwisp2/sample_pki/migrations/
                    ./tests/openwisp2/sample_connection/migrations/
                    ./tests/openwisp2/sample_geo/migrations/
                    ./tests/openwisp2/sample_subnet_division/migrations/"
